/**
 * @file iotgo_debug.h
 *
 * Provide the Macro which are used for print debug messages.
 *
 * @date   
 * @copyright 
 * 
 * 
 * 
 * 
 * 
 */

#ifndef _IOTGO_DEBUG_H_
#define _IOTGO_DEBUG_H_

#include "iotgo_platformAPI.h"

#define IOTGO_DEBUG_PLATFORM_API               (1)
#define IOTGO_DEBUG_SOCKET_SERVER              (0)
#define IOTGO_DEBUG_SOCKET_CLIENT              (0)
#define IOTGO_DEBUG_COMMUNICATION_WITH_DSERVER (1)
#define IOTGO_DEBUG_COMMUNICATION_WITH_LSERVER (1)
#define IOTGO_DEBUG_PAIR_WITH_APP              (1)
#define IOTGO_DEBUG_SERVICE                    (1)
#define IOTGO_DEBUG_DATAPOOL                   (0)
#define IOTGO_DEBUG_POLARSSL                   (0)


#if (PLATFORM == PLATFORM_ESP8266)
#define DEBUG_PRINTF os_printf
#elif (PLATFORM == PLATFORM_RTL8711 || \
       PLATFORM == PLATFORM_LINUX)
#define DEBUG_PRINTF printf
#else
#endif

#define platformDebugPrint(fmt, args...)\
    do {\
        if (IOTGO_DEBUG_PLATFORM_API) \
        {\
            DEBUG_PRINTF(fmt,##args);\
        }\
    } while(0)

#define socketServerDebugPrint(fmt, args...)\
    do {\
        if (IOTGO_DEBUG_SOCKET_SERVER) \
        {\
            DEBUG_PRINTF(fmt,##args);\
        }\
    } while(0)

#define socketClientDebugPrint(fmt, args...)\
    do {\
        if (IOTGO_DEBUG_SOCKET_CLIENT) \
        {\
            DEBUG_PRINTF(fmt,##args);\
        }\
    } while(0)

#define distriServerDebugPrint(fmt, args...)\
    do {\
        if (IOTGO_DEBUG_COMMUNICATION_WITH_DSERVER) \
        {\
            DEBUG_PRINTF(fmt,##args);\
        }\
    } while(0)

#define longServerDebugPrint(fmt, args...)\
    do {\
        if (IOTGO_DEBUG_COMMUNICATION_WITH_LSERVER) \
        {\
            DEBUG_PRINTF(fmt,##args);\
        }\
    } while(0)

#define pairWithAppDebugPrint(fmt, args...)	\
    do {\
        if (IOTGO_DEBUG_PAIR_WITH_APP) \
        {\
            DEBUG_PRINTF(fmt,##args);\
        }\
    } while(0)


#define serviceDebugPrint(fmt, args...)\
    do {\
        if (IOTGO_DEBUG_SERVICE) \
        {\
            DEBUG_PRINTF(fmt,##args);\
        }\
    } while(0)

#define dataPoolDebugPrint(fmt, args...)\
    do {\
        if (IOTGO_DEBUG_DATAPOOL) \
        {\
            DEBUG_PRINTF(fmt,##args);\
        }\
    } while(0)

#define polarsslDebugPrint(fmt, args...)\
    do {\
        if (IOTGO_DEBUG_POLARSSL) \
        {\
            DEBUG_PRINTF(fmt,##args);\
        }\
    } while(0)

#endif
